package framework.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;

import framework.exceptions.ExceptionHandler;

public class DateUtil {
    
    private final static Logger logger  = LogUtil.getInstance(DateUtil.class);

    public final static String FORMAT_TYPE_ALL="yyyy-MM-dd HH:mm:ss";
    /**
     * 格式化日期到字符串
     * @param date Date
     * @param formatStr 格式化字符串
     * @return
     */
    public static String dateFormat(Date date,String formatStr){
            SimpleDateFormat formater=null;
            try{
                     formater=new SimpleDateFormat(formatStr);

            }catch(Exception e){
                    ExceptionHandler.throwRuntimeException(e, "日期格式转换错误", logger);
            }
            return formater.format(date);
    }
}
